package com.yuhuihui.common.utils.excel.read.parameters;

import com.yuhuihui.common.utils.excel.read.VerifyRow;
import com.yuhuihui.common.utils.excel.read.convert.CellTypeConvertFactory;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * 导入参数--返回map
 *
 * @author yuhh
 * @date 2022-08-22 16:30:21
 */
public class ExcelReadMapParameter<T> {

    /**
     * 输入流
     */
    private InputStream inputStream;

    /**
     * 开始excel片区下标，默认从0开始
     */
    private Integer startSheet = 0;

    /**
     * 结束excel片区下标，不包含
     */
    private Integer endSheet = 1;

    /**
     * 开始行下标，默认从0开始
     */
    private Integer startRow = 0;

    /**
     * 结束行下标，不包含
     */
    private Integer endRow;

    /**
     * 开始列下标，默认从0开始
     */
    private Integer startCell = 0;

    /**
     * 结束列下标，不包含
     */
    private Integer endCell;

    /**
     * 列对应表头的code，必须是T的属性名
     */
    private String[] fieldCodes;

    /**
     * 需要删除的列下标
     */
    List<Integer> deleteCellNums;

    /**
     * 需要替换的数据
     * 第一个key是需要替换的字段名
     * 第二个key是excel中需要替换的值
     * 第二个value是替换后的值
     */
    private Map<String, Map<String, Object>> replaceInfo;

    /**
     * 验证行数据的函数
     */
    private VerifyRow<T> verifyRow;

    /**
     * 默认值，key为字段名称
     */
    private Map<String, Object> defaultValue;

    /**
     * 单元格类型装换工厂类，可以根据需求替换对应类型的转换方式
     */
    private CellTypeConvertFactory cellTypeConvertFactory = CellTypeConvertFactory.getInstance();

    public InputStream getInputStream() {
        return inputStream;
    }

    public ExcelReadMapParameter<T> setInputStream(InputStream inputStream) {
        this.inputStream = inputStream;
        return this;
    }

    public Integer getStartSheet() {
        return startSheet;
    }

    public ExcelReadMapParameter<T> setStartSheet(Integer startSheet) {
        this.startSheet = startSheet;
        return this;
    }

    public Integer getEndSheet() {
        return endSheet;
    }

    public ExcelReadMapParameter<T> setEndSheet(Integer endSheet) {
        this.endSheet = endSheet;
        return this;
    }

    public Integer getStartRow() {
        return startRow;
    }

    public ExcelReadMapParameter<T> setStartRow(Integer startRow) {
        this.startRow = startRow;
        return this;
    }

    public Integer getEndRow() {
        return endRow;
    }

    public ExcelReadMapParameter<T> setEndRow(Integer endRow) {
        this.endRow = endRow;
        return this;
    }

    public Integer getStartCell() {
        return startCell;
    }

    public ExcelReadMapParameter<T> setStartCell(Integer startCell) {
        this.startCell = startCell;
        return this;
    }

    public Integer getEndCell() {
        return endCell;
    }

    public ExcelReadMapParameter<T> setEndCell(Integer endCell) {
        this.endCell = endCell;
        return this;
    }

    public String[] getFieldCodes() {
        return fieldCodes;
    }

    public ExcelReadMapParameter<T> setFieldCodes(String[] fieldCodes) {
        this.fieldCodes = fieldCodes;
        return this;
    }

    public List<Integer> getDeleteCellNums() {
        return deleteCellNums;
    }

    public ExcelReadMapParameter<T> setDeleteCellNums(List<Integer> deleteCellNums) {
        this.deleteCellNums = deleteCellNums;
        return this;
    }

    public Map<String, Map<String, Object>> getReplaceInfo() {
        return replaceInfo;
    }

    public ExcelReadMapParameter<T> setReplaceInfo(Map<String, Map<String, Object>> replaceInfo) {
        this.replaceInfo = replaceInfo;
        return this;
    }

    public VerifyRow<T> getVerifyRow() {
        return verifyRow;
    }

    public ExcelReadMapParameter<T> setVerifyRow(VerifyRow<T> verifyRow) {
        this.verifyRow = verifyRow;
        return this;
    }

    public Map<String, Object> getDefaultValue() {
        return defaultValue;
    }

    public ExcelReadMapParameter<T> setDefaultValue(Map<String, Object> defaultValue) {
        this.defaultValue = defaultValue;
        return this;
    }

    public CellTypeConvertFactory getCellTypeConvertFactory() {
        return cellTypeConvertFactory;
    }

    public ExcelReadMapParameter<T> setCellTypeConvertFactory(CellTypeConvertFactory cellTypeConvertFactory) {
        this.cellTypeConvertFactory = cellTypeConvertFactory;
        return this;
    }
}
